<template>
  <div class="app-container">
    <!-- 添加或修改运单信息对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="1340px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="100px" :inline="true" size="small">
        <el-form-item v-if="singleShow" label="运单编号" prop="wayBillNumber">
          <el-input v-model="form.wayBillNumber" placeholder="请输入运单编号" :disabled="true" />
        </el-form-item>
        <!--el-form-item label="运单状态" prop="wayBillStatus">
          <el-select v-model="form.wayBillStatus" placeholder="请选择运单状态" clearable>
            <el-option
              v-for="dict in dict.type.way_bill_status"
              :key="dict.value"
              :label="dict.label"
              :value="dict.label"
            ></el-option>
          </el-select>
        </el-form-item-->
        <el-form-item label="录单时间" prop="recordTime">
          <el-date-picker clearable
            v-model="form.recordTime"
            type="datetime"
            value-format="yyyy-MM-dd HH:mm:ss"
            placeholder="请选择录单时间"
            >
          </el-date-picker>
        </el-form-item>
        <el-form-item label="计划编号" prop="transportPlanNumber">
          <el-input v-model="form.transportPlanNumber" placeholder="输计划号按回车,可模糊查询" clearable @keyup.enter.native="handleRelatePlan(form.transportPlanNumber)"/>
        </el-form-item>
        <div>
          <span :style="{ fontWeight: 'bold' }">主货信息</span> <div class="dashed-line" />
        </div>
        <el-form-item label="发货电话" prop="sendGoodsMobile">
          <el-input v-model="form.sendGoodsMobile" placeholder="请输入发货电话" clearable maxlength="13" @keyup.enter.native="handleSendGoodsMobile(form.sendGoodsMobile)" />
        </el-form-item>
        <el-form-item label="发货人" prop="sendGoodsPerson">
          <el-input v-model="form.sendGoodsPerson" placeholder="请输入发货人" clearable />
        </el-form-item>
        <el-form-item label="发货地址" prop="sendGoodsAddress">
          <el-input v-model="form.sendGoodsAddress" placeholder="请输入发货地址" clearable />
        </el-form-item>
        <!--el-form-item label="始发流向" prop="beginFlowDirection">
          <el-input v-model="form.beginFlowDirection" placeholder="请输入始发流向" clearable />
        </el-form-item-->
        <el-form-item label="发货客户" prop="sendGoodsCustomer">
          <el-select v-model="form.sendGoodsCustomer" placeholder="请选择发货客户" clearable>
            <el-option
              v-for="dict in customerOptions"
              :key="dict.customerId"
              :label="dict.customerName"
              :value="dict.customerName"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="收货电话" prop="receiveGoodsMobile">
          <el-input v-model="form.receiveGoodsMobile" placeholder="请输入收货电话" clearable maxlength="13" @keyup.enter.native="handleReceGoodsMobile(form.receiveGoodsMobile)" />
        </el-form-item>
        <el-form-item label="收货人" prop="receiveGoodsPerson">
          <el-input v-model="form.receiveGoodsPerson" placeholder="请输入收货人" clearable />
        </el-form-item>
        <el-form-item label="收货地址" prop="receiveGoodsAddress">
          <el-input v-model="form.receiveGoodsAddress" placeholder="请输入收货地址" clearable />
        </el-form-item>
        <!--el-form-item label="目的流向" prop="endFlowDirection">
          <el-input v-model="form.endFlowDirection" placeholder="请输入目的流向" clearable />
        </el-form-item-->
        <el-form-item label="收货客户" prop="receiveGoodsCustomer">
          <el-select v-model="form.receiveGoodsCustomer" placeholder="请选择收货客户" clearable>
            <el-option
              v-for="dict in customerOptions"
              :key="dict.customerId"
              :label="dict.customerName"
              :value="dict.customerName"
            ></el-option>
          </el-select>
        </el-form-item>
        <!--el-form-item label="收货备注" prop="receiveGoodsRemark">
          <el-input v-model="form.receiveGoodsRemark" placeholder="请输入收货备注" clearable />
        </el-form-item-->
        <!--div>
          <span>配货信息</span> <div class="dashed-line" />
        </div>
        <el-form-item label="发货电话" prop="minorSendGoodsMobile">
          <el-input v-model="form.minorSendGoodsMobile" placeholder="请输入发货电话" clearable />
        </el-form-item>
        <el-form-item label="发货人" prop="minorSendGoodsPerson">
          <el-input v-model="form.minorSendGoodsPerson" placeholder="请输入发货人" clearable />
        </el-form-item>
        <el-form-item label="发货地址" prop="minorSendGoodsAddress">
          <el-input v-model="form.minorSendGoodsAddress" placeholder="请输入发货地址" clearable />
        </el-form-item>
        <el-form-item label="发货客户" prop="minorSendGoodsCustomer">
          <el-select v-model="form.minorSendGoodsCustomer" placeholder="请选择发货客户" clearable>
            <el-option
              v-for="dict in customerOptions"
              :key="dict.customerId"
              :label="dict.customerName"
              :value="dict.customerName"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="收货电话" prop="minorReceiveGoodsMobile">
          <el-input v-model="form.minorReceiveGoodsMobile" placeholder="请输入收货电话" clearable />
        </el-form-item>
        <el-form-item label="收货人" prop="minorReceiveGoodsPerson">
          <el-input v-model="form.minorReceiveGoodsPerson" placeholder="请输入收货人" clearable />
        </el-form-item>
        <el-form-item label="收货地址" prop="minorReceiveGoodsAddress">
          <el-input v-model="form.minorReceiveGoodsAddress" placeholder="请输入收货地址" clearable />
        </el-form-item>
        <el-form-item label="收货客户" prop="minorReceiveGoodsCustomer">
          <el-select v-model="form.minorReceiveGoodsCustomer" placeholder="请选择收货客户" clearable>
            <el-option
              v-for="dict in customerOptions"
              :key="dict.customerId"
              :label="dict.customerName"
              :value="dict.customerName"
            ></el-option>
          </el-select>
        </el-form-item-->
        <div>
          <span :style="{ fontWeight: 'bold' }">车辆司机</span> <div class="dashed-line" />
        </div>
        <el-form-item v-if="singleShow" label="车牌号码" prop="vehicleLicenseNumber">
          <el-input v-model="form.vehicleLicenseNumber" placeholder="请输入车牌号码" clearable @change="handleChangeToUpperCase(form.vehicleLicenseNumber)" @keyup.enter.native="handleVehicleLicenseNumber(form.vehicleLicenseNumber)" />
        </el-form-item>
        <el-form-item label="车辆标记" prop="vehicleMark">
          <el-select v-model="form.vehicleMark" placeholder="请选择车辆标记" @change="handleChangeVehicleMark">
            <el-option
              v-for="dict in dict.type.vehicle_mark"
              :key="dict.value"
              :label="dict.label"
              :value="dict.label"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item v-if="singleShow" label="司机姓名" prop="driverName">
          <el-input v-model="form.driverName" placeholder="请输入司机姓名" clearable />
        </el-form-item>
        <el-form-item v-if="singleShow" label="司机电话" prop="contactMobile">
          <el-input v-model="form.contactMobile" placeholder="请输入司机电话" clearable />
        </el-form-item>
        <!--el-form-item v-if="form.vehicleMark=='外协车辆'" label="货物类型" prop="goodsType">
          <el-select v-model="form.goodsType" placeholder="请选择货物类型" clearable>
            <el-option
              v-for="dict in dict.type.goods_type"
              :key="dict.value"
              :label="dict.label"
              :value="dict.label"
            ></el-option>
          </el-select>
        </el-form-item-->
        <el-form-item v-if="form.vehicleMark=='外协车辆' && singleShow" label="重量(吨)" prop="freightWeight">
          <el-input v-model="form.freightWeight" placeholder="请输入重量(吨)" clearable @change="handleChangeRecompute" />
        </el-form-item>
        <el-form-item v-if="form.vehicleMark=='外协车辆' && singleShow" label="件数" prop="freightNumber">
          <el-input v-model="form.freightNumber" placeholder="请输入件数" clearable />
        </el-form-item>
        <el-form-item v-if="form.vehicleMark=='外协车辆'" label="运费计价" prop="freightPriceMode">
          <el-select v-model="form.freightPriceMode" placeholder="请选择运费计价" clearable @change="handleChangeRecompute">
            <el-option
              v-for="dict in dict.type.price_mode"
              :key="dict.value"
              :label="dict.label"
              :value="dict.label"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item v-if="form.vehicleMark=='外协车辆'" label="运费价格" prop="freightPrice">
          <el-input v-model="form.freightPrice" placeholder="请输入运费价格" clearable @change="handleChangeRecompute" />
        </el-form-item>
        <el-form-item v-if="form.vehicleMark=='外协车辆' && singleShow" label="主货运费" prop="freightAmount">
          <el-input v-model="form.freightAmount" placeholder="请输入运费金额" clearable />
        </el-form-item>
        <!--el-form-item label="运费补贴" prop="primage">
          <el-input v-model="form.primage" placeholder="请输入运费补贴" clearable />
        </el-form-item>
        <el-form-item label="补贴备注" prop="primageRemark">
          <el-input v-model="form.primageRemark" placeholder="请输入补贴备注" clearable />
        </el-form-item-->
        <el-form-item label="主信息费" prop="informationFee">
          <el-input v-model="form.informationFee" placeholder="请输入主信息费" clearable @change="handleChangeRecompute" />
        </el-form-item>
        <el-form-item v-if="form.vehicleMark=='外协车辆'" label="装卸费用" prop="handleCost">
          <el-input v-model="form.handleCost" placeholder="请输入装卸费用" clearable @change="handleChangeRecompute" />
        </el-form-item>
        <!--el-form-item v-if="form.vehicleMark=='外协车辆'" label="配货运费" prop="minorFreightAmount">
          <el-input v-model="form.minorFreightAmount" placeholder="请输入运费金额" clearable />
        </el-form-item-->
        <el-form-item v-if="form.vehicleMark=='外协车辆' && singleShow" prop="freightTotalAmount">
          <template slot="label">
            <div style="color: red;">运费总额</div>
          </template>
          <el-input v-model="form.freightTotalAmount" placeholder="请输入运费总额" clearable />
        </el-form-item>
        <!--el-form-item label="付款方式" prop="freightPaymentMethod">
          <el-select v-model="form.freightPaymentMethod" placeholder="请选择付款方式" clearable>
            <el-option
              v-for="dict in dict.type.payment_mode"
              :key="dict.value"
              :label="dict.label"
              :value="dict.label"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="付款状态" prop="freightPaymentStatus">
          <el-select v-model="form.freightPaymentStatus" placeholder="请选择付款状态" clearable>
            <el-option
              v-for="dict in dict.type.payment_status"
              :key="dict.value"
              :label="dict.label"
              :value="dict.label"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="付款人" prop="freightPaymentPerson">
          <el-input v-model="form.freightPaymentPerson" placeholder="请输入付款人" clearable />
        </el-form-item>
        <el-form-item label="付款日期" prop="freightPaymentDate">
          <el-date-picker clearable
            v-model="form.freightPaymentDate"
            type="datetime"
            value-format="yyyy-MM-dd HH:mm:ss"
            placeholder="请选择付款日期"
            >
          </el-date-picker>
        </el-form-item-->
        <div>
          <span :style="{ fontWeight: 'bold' }">主货结算</span> <div class="dashed-line" />
        </div>
        <el-form-item v-if="singleShow" label="货物类型" prop="goodsType">
          <el-select v-model="form.goodsType" placeholder="请选择货物类型" clearable>
            <el-option
              v-for="dict in dict.type.goods_type"
              :key="dict.value"
              :label="dict.label"
              :value="dict.label"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item v-if="singleShow" label="重量(吨)" prop="freightWeight">
          <el-input v-model="form.freightWeight" placeholder="请输入重量(吨)" clearable @change="handleChangeRecompute" />
        </el-form-item>
        <el-form-item v-if="singleShow" label="件数" prop="freightNumber">
          <el-input v-model="form.freightNumber" placeholder="请输入件数" clearable />
        </el-form-item>
        <el-form-item label="结算计价" prop="settlementPriceMode">
          <el-select v-model="form.settlementPriceMode" placeholder="请选择结算计价" clearable @change="handleChangeRecompute">
            <el-option
              v-for="dict in dict.type.price_mode"
              :key="dict.value"
              :label="dict.label"
              :value="dict.label"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="结算价格" prop="settlementPrice">
          <el-input v-model="form.settlementPrice" placeholder="请输入结算价格" clearable @change="handleChangeRecompute" />
        </el-form-item>
        <el-form-item v-if="singleShow" label="结算金额" prop="settlementAmount">
          <el-input v-model="form.settlementAmount" placeholder="请输入结算金额" clearable @change="handleSettlementTotalAmount" />
        </el-form-item>
        <!--el-form-item label="附加运费" prop="premium">
          <el-input v-model="form.premium" placeholder="请输入附加运费" clearable />
        </el-form-item>
        <el-form-item label="附加备注" prop="premiumRemark">
          <el-input v-model="form.premiumRemark" placeholder="请输入附加备注" clearable />
        </el-form-item-->
        <el-form-item label="结算客户" prop="settlementCustomer">
          <el-select v-model="form.settlementCustomer" placeholder="请选择结算客户" clearable>
            <el-option
              v-for="dict in customerOptions"
              :key="dict.customerId"
              :label="dict.customerName"
              :value="dict.customerName"
            ></el-option>
          </el-select>
        </el-form-item>
        <!--el-form-item prop="settlementTotalAmount">
          <template slot="label">
            <div style="color: red;">结算总额</div>
          </template>
          <el-input v-model="form.settlementTotalAmount" placeholder="请输入结算总额" clearable />
        </el-form-item-->
        <!--el-form-item label="运单备注" prop="wayBillRemark">
          <el-input v-model="form.wayBillRemark" placeholder="请输入运单备注" clearable />
        </el-form-item-->
        <!--el-form-item label="结算客户" prop="settlementCustomer">
          <el-select v-model="form.settlementCustomer" placeholder="请选择结算客户" clearable>
            <el-option
              v-for="dict in customerOptions"
              :key="dict.customerId"
              :label="dict.customerName"
              :value="dict.customerName"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="结算方式" prop="settlementMethod">
          <el-select v-model="form.settlementMethod" placeholder="请选择结算方式" clearable>
            <el-option
              v-for="dict in dict.type.settlement_mode"
              :key="dict.value"
              :label="dict.label"
              :value="dict.label"
            ></el-option>
          </el-select>
        </el-form-item-->
        <!--el-form-item label="结算状态" prop="settlementStatus">
          <el-select v-model="form.settlementStatus" placeholder="请选择结算状态" clearable>
            <el-option
              v-for="dict in dict.type.settlement_status"
              :key="dict.value"
              :label="dict.label"
              :value="dict.label"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="结算人" prop="settlementPerson">
          <el-input v-model="form.settlementPerson" placeholder="请输入结算人" clearable />
        </el-form-item>
        <el-form-item label="结算日期" prop="settlementDate">
          <el-date-picker clearable
            v-model="form.settlementDate"
            type="datetime"
            value-format="yyyy-MM-dd HH:mm:ss"
            placeholder="请选择结算日期"
            >
          </el-date-picker>
        </el-form-item-->
        <!--div>
          <span>配货结算</span> <div class="dashed-line" />
        </div>
        <el-form-item label="货物类型" prop="minorGoodsType">
          <el-select v-model="form.minorGoodsType" placeholder="请选择货物类型" clearable>
            <el-option
              v-for="dict in dict.type.goods_type"
              :key="dict.value"
              :label="dict.label"
              :value="dict.label"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="重量(吨)" prop="minorFreightWeight">
          <el-input v-model="form.minorFreightWeight" placeholder="请输入重量(吨)" clearable @change="handleChangeRecompute" />
        </el-form-item>
        <el-form-item label="件数" prop="minorFreightNumber">
          <el-input v-model="form.minorFreightNumber" placeholder="请输入件数" clearable />
        </el-form-item-->
        <!--el-form-item label="运费计价" prop="minorFreightPriceMode">
          <el-select v-model="form.minorFreightPriceMode" placeholder="请选择运费计价" clearable>
            <el-option
              v-for="dict in dict.type.price_mode"
              :key="dict.value"
              :label="dict.label"
              :value="dict.label"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="运费价格" prop="minorFreightPrice">
          <el-input v-model="form.minorFreightPrice" placeholder="请输入运费价格" clearable />
        </el-form-item>
        <el-form-item label="运费金额" prop="minorFreightAmount">
          <el-input v-model="form.minorFreightAmount" placeholder="请输入运费金额" clearable />
        </el-form-item-->
        <!--el-form-item label="结算计价" prop="minorSettlementPriceMode">
          <el-select v-model="form.minorSettlementPriceMode" placeholder="请选择结算计价" clearable @change="handleChangeRecompute">
            <el-option
              v-for="dict in dict.type.price_mode"
              :key="dict.value"
              :label="dict.label"
              :value="dict.label"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="结算价格" prop="minorSettlementPrice">
          <el-input v-model="form.minorSettlementPrice" placeholder="请输入结算价格" clearable @change="handleChangeRecompute" />
        </el-form-item>
        <el-form-item label="结算金额" prop="minorSettlementAmount">
          <el-input v-model="form.minorSettlementAmount" placeholder="请输入结算金额" clearable @change="handleSettlementTotalAmount" />
        </el-form-item>
        <el-form-item label="结算客户" prop="minorSettlementCustomer">
          <el-select v-model="form.minorSettlementCustomer" placeholder="请选择结算客户" clearable>
            <el-option
              v-for="dict in customerOptions"
              :key="dict.customerId"
              :label="dict.customerName"
              :value="dict.customerName"
            ></el-option>
          </el-select>
        </el-form-item-->
        <!--el-form-item label="结算方式" prop="minorSettlementMethod">
          <el-select v-model="form.minorSettlementMethod" placeholder="请选择结算方式" clearable>
            <el-option
              v-for="dict in dict.type.settlement_mode"
              :key="dict.value"
              :label="dict.label"
              :value="dict.label"
            ></el-option>
          </el-select>
        </el-form-item-->
        <!--el-form-item label="结算状态" prop="minorSettlementStatus">
          <el-select v-model="form.minorSettlementStatus" placeholder="请选择结算状态" clearable>
            <el-option
              v-for="dict in dict.type.settlement_status"
              :key="dict.value"
              :label="dict.label"
              :value="dict.label"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="结算人" prop="minorSettlementPerson">
          <el-input v-model="form.minorSettlementPerson" placeholder="请输入结算人" clearable />
        </el-form-item>
        <el-form-item label="结算日期" prop="minorSettlementDate">
          <el-date-picker clearable
            v-model="form.minorSettlementDate"
            type="datetime"
            value-format="yyyy-MM-dd HH:mm:ss"
            placeholder="请选择结算日期"
            >
          </el-date-picker>
        </el-form-item-->
        <!--el-form-item label="结算计价" prop="extraSettlementPriceMode">
          <el-select v-model="form.extraSettlementPriceMode" placeholder="请选择结算计价" clearable>
            <el-option
              v-for="dict in dict.type.price_mode"
              :key="dict.value"
              :label="dict.label"
              :value="dict.label"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="结算价格" prop="extraSettlementPrice">
          <el-input v-model="form.extraSettlementPrice" placeholder="请输入结算价格" clearable />
        </el-form-item>
        <el-form-item label="结算税点" prop="extraSettlementTax">
          <el-input v-model="form.extraSettlementTax" placeholder="请输入结算税点" clearable />
        </el-form-item>
        <el-form-item label="结算金额" prop="extraSettlementAmount">
          <el-input v-model="form.extraSettlementAmount" placeholder="请输入结算金额" clearable />
        </el-form-item>
        <el-form-item label="结算客户" prop="extraSettlementCustomer">
          <el-select v-model="form.extraSettlementCustomer" placeholder="请选择结算客户" clearable>
            <el-option
              v-for="dict in dict.type.sys_yes_no"
              :key="dict.value"
              :label="dict.label"
              :value="dict.label"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="结算方式" prop="extraSettlementMethod">
          <el-select v-model="form.extraSettlementMethod" placeholder="请选择结算方式" clearable>
            <el-option
              v-for="dict in dict.type.settlement_mode"
              :key="dict.value"
              :label="dict.label"
              :value="dict.label"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="结算状态" prop="extraSettlementStatus">
          <el-select v-model="form.extraSettlementStatus" placeholder="请选择结算状态" clearable>
            <el-option
              v-for="dict in dict.type.settlement_status"
              :key="dict.value"
              :label="dict.label"
              :value="dict.label"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="结算人" prop="extraSettlementPerson">
          <el-input v-model="form.extraSettlementPerson" placeholder="请输入结算人" clearable />
        </el-form-item>
        <el-form-item label="结算日期" prop="extraSettlementDate">
          <el-date-picker clearable
            v-model="form.extraSettlementDate"
            type="datetime"
            value-format="yyyy-MM-dd HH:mm:ss"
            placeholder="请选择结算日期"
            >
          </el-date-picker>
        </el-form-item-->
        <!--el-form-item label="推送仓库状态" prop="pushWmsStatus">
          <el-select v-model="form.pushWmsStatus" placeholder="请选择推送仓库状态" clearable>
            <el-option
              v-for="dict in dict.type.push_wms_status"
              :key="dict.value"
              :label="dict.label"
              :value="dict.label"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="发送短信状态" prop="sendSmsStatus">
          <el-select v-model="form.sendSmsStatus" placeholder="请选择发送短信状态" clearable>
            <el-option
              v-for="dict in dict.type.send_sms_status"
              :key="dict.value"
              :label="dict.label"
              :value="dict.label"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="接单状态" prop="receiveOrderStatus">
          <el-select v-model="form.receiveOrderStatus" placeholder="请选择接单状态" clearable>
            <el-option
              v-for="dict in dict.type.receive_order_status"
              :key="dict.value"
              :label="dict.label"
              :value="dict.label"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="装车重量(吨)" prop="loadWeight">
          <el-input v-model="form.loadWeight" placeholder="请输入装车重量(吨)" clearable />
        </el-form-item>
        <el-form-item label="装车时间" prop="loadTime">
          <el-date-picker clearable
            v-model="form.loadTime"
            type="datetime"
            value-format="yyyy-MM-dd HH:mm:ss"
            placeholder="请选择装车时间"
            >
          </el-date-picker>
        </el-form-item>
        <el-form-item label="装车图片" prop="loadPicture">
          <image-upload v-model="form.loadPicture" :limit="1"/>
        </el-form-item>
        <el-form-item label="卸车重量(吨)" prop="unloadWeight">
          <el-input v-model="form.unloadWeight" placeholder="请输入卸车重量(吨)" clearable />
        </el-form-item>
        <el-form-item label="卸车时间" prop="unloadTime">
          <el-date-picker clearable
            v-model="form.unloadTime"
            type="datetime"
            value-format="yyyy-MM-dd HH:mm:ss"
            placeholder="请选择卸车时间"
            >
          </el-date-picker>
        </el-form-item>
        <el-form-item label="卸车图片" prop="unloadPicture">
          <image-upload v-model="form.unloadPicture" :limit="1"/>
        </el-form-item>
        <el-form-item label="签收状态" prop="signStatus">
          <el-select v-model="form.signStatus" placeholder="请选择签收状态" clearable>
            <el-option
              v-for="dict in dict.type.sign_status"
              :key="dict.value"
              :label="dict.label"
              :value="dict.label"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="签收重量(吨)" prop="signWeight">
          <el-input v-model="form.signWeight" placeholder="请输入签收重量(吨)" clearable />
        </el-form-item>
        <el-form-item label="签收人" prop="signPerson">
          <el-input v-model="form.signPerson" placeholder="请输入签收人" clearable />
        </el-form-item>
        <el-form-item label="签收日期" prop="signDate">
          <el-date-picker clearable
            v-model="form.signDate"
            type="datetime"
            value-format="yyyy-MM-dd HH:mm:ss"
            placeholder="请选择签收日期"
            >
          </el-date-picker>
        </el-form-item>
        <el-form-item label="是否货损" prop="goodsDamage">
          <el-radio-group v-model="form.goodsDamage">
            <el-radio
              v-for="dict in dict.type.sys_yes_no"
              :key="dict.value"
              :label="dict.value"
            >{{dict.label}}</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="货损照片" prop="goodsDamagePicture">
          <image-upload v-model="form.goodsDamagePicture" :limit="1"/>
        </el-form-item>
        <el-form-item label="是否事故" prop="trafficAccident">
          <el-radio-group v-model="form.trafficAccident">
            <el-radio
              v-for="dict in dict.type.sys_yes_no"
              :key="dict.value"
              :label="dict.value"
            >{{dict.label}}</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="事故照片" prop="trafficAccidentPicture">
          <image-upload v-model="form.trafficAccidentPicture" :limit="1"/>
        </el-form-item>
        <el-form-item label="延迟付费" prop="delayPayment">
          <el-radio-group v-model="form.delayPayment">
            <el-radio
              v-for="dict in dict.type.sys_yes_no"
              :key="dict.value"
              :label="dict.value"
            >{{dict.label}}</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="签收备注" prop="signRemark">
          <el-input v-model="form.signRemark" placeholder="请输入签收备注" clearable />
        </el-form-item>
        <el-form-item label="签收图片" prop="signPicture">
          <image-upload v-model="form.signPicture" :limit="1"/>
        </el-form-item>
        <el-form-item label="审核结果" prop="signReviewResult">
          <el-select v-model="form.signReviewResult" placeholder="请选择审核结果" clearable>
            <el-option
              v-for="dict in dict.type.audit_pass_return"
              :key="dict.value"
              :label="dict.label"
              :value="dict.label"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="审核备注" prop="signReviewRemark">
          <el-input v-model="form.signReviewRemark" placeholder="请输入审核备注" clearable />
        </el-form-item>
        <el-form-item label="签收审核人" prop="signReviewPerson">
          <el-input v-model="form.signReviewPerson" placeholder="请输入签收审核人" clearable />
        </el-form-item>
        <el-form-item label="签收审核时间" prop="signReviewTime">
          <el-date-picker clearable
            v-model="form.signReviewTime"
            type="datetime"
            value-format="yyyy-MM-dd HH:mm:ss"
            placeholder="请选择签收审核时间"
            >
          </el-date-picker>
        </el-form-item>
        <el-form-item label="回单状态" prop="returnDocumentStatus">
          <el-select v-model="form.returnDocumentStatus" placeholder="请选择回单状态" clearable>
            <el-option
              v-for="dict in dict.type.return_document_status"
              :key="dict.value"
              :label="dict.label"
              :value="dict.label"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="回单备注" prop="returnDocumentRemark">
          <el-input v-model="form.returnDocumentRemark" placeholder="请输入回单备注" clearable />
        </el-form-item>
        <el-form-item label="回单人" prop="returnDocumentPerson">
          <el-input v-model="form.returnDocumentPerson" placeholder="请输入回单人" clearable />
        </el-form-item>
        <el-form-item label="回单时间" prop="returnDocumentTime">
          <el-date-picker clearable
            v-model="form.returnDocumentTime"
            type="datetime"
            value-format="yyyy-MM-dd HH:mm:ss"
            placeholder="请选择回单时间"
            >
          </el-date-picker>
        </el-form-item>
        <el-form-item label="现金加气" prop="cashRefuel">
          <el-input v-model="form.cashRefuel" placeholder="请输入现金加气" clearable />
        </el-form-item>
        <el-form-item label="定点加气" prop="designateRefuel">
          <el-input v-model="form.designateRefuel" placeholder="请输入定点加气" clearable />
        </el-form-item>
        <el-form-item label="路费(现金)" prop="tollFeeCash">
          <el-input v-model="form.tollFeeCash" placeholder="请输入路费(现金)" clearable />
        </el-form-item>
        <el-form-item label="路费(ETC)" prop="tollFeeEtc">
          <el-input v-model="form.tollFeeEtc" placeholder="请输入路费(ETC)" clearable />
        </el-form-item>
        <el-form-item label="罚款" prop="forfeit">
          <el-input v-model="form.forfeit" placeholder="请输入罚款" clearable />
        </el-form-item>
        <el-form-item label="主信息费" prop="informationFee">
          <el-input v-model="form.informationFee" placeholder="请输入主信息费" clearable />
        </el-form-item>
        <el-form-item label="配信息费" prop="minorInformationFee">
          <el-input v-model="form.minorInformationFee" placeholder="请输入配信息费" clearable />
        </el-form-item>
        <el-form-item label="修车费" prop="repairTruckFee">
          <el-input v-model="form.repairTruckFee" placeholder="请输入修车费" clearable />
        </el-form-item>
        <el-form-item label="服务站修车" prop="serviceStationRepair">
          <el-input v-model="form.serviceStationRepair" placeholder="请输入服务站修车" clearable />
        </el-form-item>
        <el-form-item label="轮胎费" prop="tireFee">
          <el-input v-model="form.tireFee" placeholder="请输入轮胎费" clearable />
        </el-form-item>
        <el-form-item label="其他" prop="otherFee">
          <el-input v-model="form.otherFee" placeholder="请输入其他" clearable />
        </el-form-item>
        <el-form-item label="保险费" prop="insurancePremium">
          <el-input v-model="form.insurancePremium" placeholder="请输入保险费" clearable />
        </el-form-item>
        <el-form-item label="车船税" prop="vehicleVesselTax">
          <el-input v-model="form.vehicleVesselTax" placeholder="请输入车船税" clearable />
        </el-form-item>
        <el-form-item label="北斗费" prop="greatDipperFee">
          <el-input v-model="form.greatDipperFee" placeholder="请输入北斗费" clearable />
        </el-form-item>
        <el-form-item label="气瓶证费" prop="gasCylinderFee">
          <el-input v-model="form.gasCylinderFee" placeholder="请输入气瓶证费" clearable />
        </el-form-item>
        <el-form-item label="支出总计" prop="expenseTotal">
          <el-input v-model="form.expenseTotal" placeholder="请输入支出总计" clearable />
        </el-form-item>
        <el-form-item label="利润" prop="profit">
          <el-input v-model="form.profit" placeholder="请输入利润" clearable />
        </el-form-item>
        <el-form-item label="挂账状态" prop="pendAccountStatus">
          <el-select v-model="form.pendAccountStatus" placeholder="请选择挂账状态" clearable>
            <el-option
              v-for="dict in dict.type.pend_account_status"
              :key="dict.value"
              :label="dict.label"
              :value="dict.label"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="挂账人" prop="pendAccountPerson">
          <el-input v-model="form.pendAccountPerson" placeholder="请输入挂账人" clearable />
        </el-form-item>
        <el-form-item label="挂账时间" prop="pendAccountTime">
          <el-date-picker clearable
            v-model="form.pendAccountTime"
            type="datetime"
            value-format="yyyy-MM-dd HH:mm:ss"
            placeholder="请选择挂账时间"
            >
          </el-date-picker>
        </el-form-item>
        <el-form-item label="挂账审核状态" prop="pendAccountAuditStatus">
          <el-select v-model="form.pendAccountAuditStatus" placeholder="请选择挂账审核状态" clearable>
            <el-option
              v-for="dict in dict.type.audit_pass_return"
              :key="dict.value"
              :label="dict.label"
              :value="dict.label"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="挂账审核人" prop="pendAccountAuditPerson">
          <el-input v-model="form.pendAccountAuditPerson" placeholder="请输入挂账审核人" clearable />
        </el-form-item>
        <el-form-item label="挂账审核时间" prop="pendAccountAuditTime">
          <el-date-picker clearable
            v-model="form.pendAccountAuditTime"
            type="datetime"
            value-format="yyyy-MM-dd HH:mm:ss"
            placeholder="请选择挂账审核时间"
            >
          </el-date-picker>
        </el-form-item>
        <el-form-item label="运费账单状态" prop="freightBillStatus">
          <el-select v-model="form.freightBillStatus" placeholder="请选择运费账单状态" clearable>
            <el-option
              v-for="dict in dict.type.bill_status"
              :key="dict.value"
              :label="dict.label"
              :value="dict.label"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="运费账单编号" prop="freightBillNumber">
          <el-input v-model="form.freightBillNumber" placeholder="请输入运费账单编号" clearable />
        </el-form-item>
        <el-form-item label="结算账单状态" prop="settlementBillStatus">
          <el-select v-model="form.settlementBillStatus" placeholder="请选择结算账单状态" clearable>
            <el-option
              v-for="dict in dict.type.bill_status"
              :key="dict.value"
              :label="dict.label"
              :value="dict.label"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="结算账单编号" prop="settlementBillNumber">
          <el-input v-model="form.settlementBillNumber" placeholder="请输入结算账单编号" clearable />
        </el-form-item>
        <el-form-item label="利润账单编号" prop="profitBillNumber">
          <el-input v-model="form.profitBillNumber" placeholder="请输入利润账单编号" clearable />
        </el-form-item>
        <el-form-item label="发票状态" prop="invoiceStatus">
          <el-select v-model="form.invoiceStatus" placeholder="请选择发票状态" clearable>
            <el-option
              v-for="dict in dict.type.invoice_status"
              :key="dict.value"
              :label="dict.label"
              :value="dict.label"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="发票编号" prop="invoiceNumber">
          <el-input v-model="form.invoiceNumber" placeholder="请输入发票编号" clearable />
        </el-form-item>
        <el-form-item label="快递单号" prop="invoiceExpressNumber">
          <el-input v-model="form.invoiceExpressNumber" placeholder="请输入快递单号" clearable />
        </el-form-item>
        <el-form-item label="回程运单" prop="returnWayBillMark">
          <el-input v-model="form.returnWayBillMark" placeholder="请输入回程运单" clearable />
        </el-form-item>
        <el-form-item label="去程单号" prop="upwardWayBillNumber">
          <el-input v-model="form.upwardWayBillNumber" placeholder="请输入去程单号" clearable />
        </el-form-item>
        <el-form-item label="回程单号" prop="downwardWayBillNumber">
          <el-input v-model="form.downwardWayBillNumber" placeholder="请输入回程单号" clearable />
        </el-form-item>
        <el-form-item label="运单标记" prop="wayBillMark">
          <el-select v-model="form.wayBillMark" placeholder="请选择运单标记" clearable>
            <el-option
              v-for="dict in dict.type.way_bill_mark"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="计划编号" prop="transportPlanNumber">
          <el-input v-model="form.transportPlanNumber" placeholder="请输入计划编号" clearable />
        </el-form-item>
        <el-form-item label="园区代码" prop="parkCode">
          <el-input v-model="form.parkCode" placeholder="请输入园区代码" clearable />
        </el-form-item-->
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { listWaybill, getWaybill, delWaybill, addWaybill, updateWaybill, addWaybillByExitIds } from "@/api/waybills/waybill";
import { listFlowOption, updateFlow } from "@/api/system/flow";
import { getPersonAddress } from "@/api/system/sendrece";
import { getDriverMobile } from "@/api/system/vehicledriver";
import { listNumber, getNumber, getOneNumber, delNumber, addNumber, updateNumber } from "@/api/system/number";
import { listCustomerOption } from "@/api/customs/custom";
import { isNotNull } from "@/utils/validate";
import { getPlanExt } from "@/api/transport/plan";

export default {
  name: "WaybillDialog",
  dicts: ['vehicle_mark', 'invoice_status', 'send_sms_status', 'sys_yes_no', 'payment_mode', 'payment_status', 'audit_pass_return', 'goods_type', 'settlement_status', 'price_mode', 'settlement_mode', 'push_wms_status', 'sign_status', 'return_document_status', 'pend_account_status', 'way_bill_status', 'receive_order_status', 'bill_status'],
  data() {
    return {
      // 定义列表高度
      tableHeight: 430,
      // 定义查询高度
      queryHeight: 200,
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 大于1个禁用
      zeroOne: false,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 运单信息表格数据
      waybillList: [],
      //选择列表
      selectList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 园区代码时间范围
      daterangeRecordTime: [],
      // 园区代码时间范围
      daterangeLoadTime: [],
      // 园区代码时间范围
      daterangeUnloadTime: [],
      // 园区代码时间范围
      daterangeSignDate: [],
      // 园区代码时间范围
      daterangeSignReviewTime: [],
      // 园区代码时间范围
      daterangeReturnDocumentTime: [],
      // 园区代码时间范围
      daterangePendAccountTime: [],
      // 园区代码时间范围
      daterangePendAccountAuditTime: [],
      // 园区代码时间范围
      daterangeCreateTime: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        bundleNumber: null,
        wayBillNumber: null,
        wayBillStatus: null,
        recordTime: null,
        sendGoodsMobile: null,
        sendGoodsPerson: null,
        sendGoodsAddress: null,
        beginFlowDirection: null,
        sendGoodsCustomer: null,
        receiveGoodsMobile: null,
        receiveGoodsPerson: null,
        receiveGoodsAddress: null,
        endFlowDirection: null,
        receiveGoodsCustomer: null,
        receiveGoodsRemark: null,
        minorSendGoodsMobile: null,
        minorSendGoodsPerson: null,
        minorSendGoodsAddress: null,
        minorSendGoodsCustomer: null,
        minorReceiveGoodsMobile: null,
        minorReceiveGoodsPerson: null,
        minorReceiveGoodsAddress: null,
        minorReceiveGoodsCustomer: null,
        vehicleLicenseNumber: null,
        vehicleMark: null,
        driverName: null,
        contactMobile: null,
        goodsType: null,
        freightWeight: null,
        freightNumber: null,
        freightPriceMode: null,
        freightPrice: null,
        freightAmount: null,
        primage: null,
        primageRemark: null,
        handleCost: null,
        freightTotalAmount: null,
        freightPaymentMethod: null,
        freightPaymentStatus: null,
        freightPaymentPerson: null,
        freightPaymentDate: null,
        settlementPriceMode: null,
        settlementPrice: null,
        settlementAmount: null,
        premium: null,
        premiumRemark: null,
        settlementTotalAmount: null,
        wayBillRemark: null,
        settlementCustomer: null,
        settlementMethod: null,
        settlementStatus: null,
        settlementPerson: null,
        settlementDate: null,
        minorGoodsType: null,
        minorFreightWeight: null,
        minorFreightNumber: null,
        minorFreightPriceMode: null,
        minorFreightPrice: null,
        minorFreightAmount: null,
        minorSettlementPriceMode: null,
        minorSettlementPrice: null,
        minorSettlementAmount: null,
        minorSettlementCustomer: null,
        minorSettlementMethod: null,
        minorSettlementStatus: null,
        minorSettlementPerson: null,
        minorSettlementDate: null,
        extraSettlementPriceMode: null,
        extraSettlementPrice: null,
        extraSettlementTax: null,
        extraSettlementAmount: null,
        extraSettlementCustomer: null,
        extraSettlementMethod: null,
        extraSettlementStatus: null,
        extraSettlementPerson: null,
        extraSettlementDate: null,
        pushWmsStatus: null,
        sendSmsStatus: null,
        receiveOrderStatus: null,
        loadWeight: null,
        loadTime: null,
        loadPicture: null,
        unloadWeight: null,
        unloadTime: null,
        unloadPicture: null,
        signStatus: null,
        signWeight: null,
        signPerson: null,
        signDate: null,
        goodsDamage: null,
        goodsDamagePicture: null,
        trafficAccident: null,
        trafficAccidentPicture: null,
        delayPayment: null,
        signRemark: null,
        signPicture: null,
        signReviewResult: null,
        signReviewRemark: null,
        signReviewPerson: null,
        signReviewTime: null,
        returnDocumentStatus: null,
        returnDocumentRemark: null,
        returnDocumentPerson: null,
        returnDocumentTime: null,
        cashRefuel: null,
        designateRefuel: null,
        tollFeeCash: null,
        tollFeeEtc: null,
        forfeit: null,
        informationFee: null,
        minorInformationFee: null,
        repairTruckFee: null,
        serviceStationRepair: null,
        tireFee: null,
        otherFee: null,
        insurancePremium: null,
        vehicleVesselTax: null,
        greatDipperFee: null,
        gasCylinderFee: null,
        expenseTotal: null,
        profit: null,
        pendAccountStatus: null,
        pendAccountPerson: null,
        pendAccountTime: null,
        pendAccountAuditStatus: null,
        pendAccountAuditPerson: null,
        pendAccountAuditTime: null,
        freightBillStatus: null,
        freightBillNumber: null,
        settlementBillStatus: null,
        settlementBillNumber: null,
        profitBillNumber: null,
        invoiceStatus: null,
        invoiceNumber: null,
        invoiceExpressNumber: null,
        returnWayBillMark: null,
        upwardWayBillNumber: null,
        downwardWayBillNumber: null,
        wayBillMark: null,
        transportPlanNumber: null,
        parkCode: null,
        createBy: null,
        createTime: null,
      },
      // 表单参数
      form: {},
      // 字典项始发流向
      beginFlowOptions: [],
      // 字典项目的流向
      endFlowOptions: [],
      // 字典项客户
      customerOptions: [],
      // 已选行
      hasSelectRow: [],
      // 出库单号
      exitWarehouseNumber: "",
      // 出库单据
      exitWarehouseRows: [],
      // 出库单ID
      exitWarehouseIds: [],
      // 批量隐藏
      singleShow: true,
      // 表单校验
      rules: {
        transportPlanNumber: [
          { required: true, message: "计划编号不能为空", trigger: "blur" }
        ],
      }
    };
  },
  created() {
    this.getOption();
  },
  mounted() {
  },
  methods: {
    // 窗口初始化方法，nextTick方法可以添加逻辑，如打开窗口时查询数据填充
    init(open, title, exitWarehouseIds, exitWarehouseRows) {
      this.open = open;
      this.title = title;
      this.exitWarehouseIds = exitWarehouseIds;
      this.exitWarehouseRows = exitWarehouseRows;

      this.reset();
      this.$set(this.form, 'recordTime', this.parseTime(new Date(), '{y}-{m}-{d} {h}:{i}:{s}'));
      if(exitWarehouseIds.length > 1) {
        this.$set(this.form, 'vehicleMark', '自有车辆');
        this.singleShow = false;
      } else {
        const numberPersistenceId = 1
        getOneNumber(numberPersistenceId).then(response => {
          let number = new String(response.data.number);
          let format = "000000000"; //"123456789";
          let length = number.length;
          if(length < 10) {
            this.$set(this.form, 'wayBillNumber', format.substring(0, 9 - length) + number);
          } else {
            this.$set(this.form, 'wayBillNumber', number.substring(length - 9, length));
          }
        });
        const exitWarehouseRow = exitWarehouseRows[0];
        this.$set(this.form, 'wayBillStatus', '运输中'); // 初始状态：待发运
        this.$set(this.form, 'freightPaymentStatus', '未付款');
        this.$set(this.form, 'settlementStatus', '未结算');
        this.$set(this.form, 'minorSettlementStatus', '未结算');
        this.$set(this.form, 'signStatus', '未签收');
        this.$set(this.form, 'pendAccountStatus', '未挂账');
        //this.$set(this.form, 'recordTime', this.parseTime(new Date(), '{y}-{m}-{d} {h}:{i}:{s}'));
        this.$set(this.form, 'sendGoodsCustomer', exitWarehouseRow.exitWarehouseCustomer);
        this.$set(this.form, 'vehicleLicenseNumber', exitWarehouseRow.exitWarehouseVehicle);
        this.$set(this.form, 'vehicleMark', '自有车辆');
        this.$set(this.form, 'driverName', exitWarehouseRow.exitWarehouseDriver);
        this.$set(this.form, 'contactMobile', exitWarehouseRow.exitWarehouseMobile);
        this.$set(this.form, 'goodsType', exitWarehouseRow.goodsType);
        this.$set(this.form, 'freightWeight', exitWarehouseRow.weight);
        this.$set(this.form, 'freightNumber', exitWarehouseRow.numberOfPiece);
        this.singleShow = true;
      }
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        wayBillId: null,
        wayBillNumber: null,
        wayBillStatus: null,
        recordTime: null,
        sendGoodsMobile: null,
        sendGoodsPerson: null,
        sendGoodsAddress: null,
        beginFlowDirection: null,
        sendGoodsCustomer: null,
        receiveGoodsMobile: null,
        receiveGoodsPerson: null,
        receiveGoodsAddress: null,
        endFlowDirection: null,
        receiveGoodsCustomer: null,
        receiveGoodsRemark: null,
        minorSendGoodsMobile: null,
        minorSendGoodsPerson: null,
        minorSendGoodsAddress: null,
        minorSendGoodsCustomer: null,
        minorReceiveGoodsMobile: null,
        minorReceiveGoodsPerson: null,
        minorReceiveGoodsAddress: null,
        minorReceiveGoodsCustomer: null,
        vehicleLicenseNumber: null,
        vehicleMark: null,
        driverName: null,
        contactMobile: null,
        goodsType: null,
        freightWeight: null,
        freightNumber: null,
        freightPriceMode: null,
        freightPrice: null,
        freightAmount: null,
        primage: null,
        primageRemark: null,
        handleCost: null,
        freightTotalAmount: null,
        freightPaymentMethod: null,
        freightPaymentStatus: null,
        freightPaymentPerson: null,
        freightPaymentDate: null,
        settlementPriceMode: null,
        settlementPrice: null,
        settlementAmount: null,
        premium: null,
        premiumRemark: null,
        settlementTotalAmount: null,
        wayBillRemark: null,
        settlementCustomer: null,
        settlementMethod: null,
        settlementStatus: null,
        settlementPerson: null,
        settlementDate: null,
        minorGoodsType: null,
        minorFreightWeight: null,
        minorFreightNumber: null,
        minorFreightPriceMode: null,
        minorFreightPrice: null,
        minorFreightAmount: null,
        minorSettlementPriceMode: null,
        minorSettlementPrice: null,
        minorSettlementAmount: null,
        minorSettlementCustomer: null,
        minorSettlementMethod: null,
        minorSettlementStatus: null,
        minorSettlementPerson: null,
        minorSettlementDate: null,
        extraSettlementPriceMode: null,
        extraSettlementPrice: null,
        extraSettlementTax: null,
        extraSettlementAmount: null,
        extraSettlementCustomer: null,
        extraSettlementMethod: null,
        extraSettlementStatus: null,
        extraSettlementPerson: null,
        extraSettlementDate: null,
        pushWmsStatus: null,
        sendSmsStatus: null,
        receiveOrderStatus: null,
        loadWeight: null,
        loadTime: null,
        loadPicture: null,
        unloadWeight: null,
        unloadTime: null,
        unloadPicture: null,
        signStatus: null,
        signWeight: null,
        signPerson: null,
        signDate: null,
        goodsDamage: null,
        goodsDamagePicture: null,
        trafficAccident: null,
        trafficAccidentPicture: null,
        delayPayment: null,
        signRemark: null,
        signPicture: null,
        signReviewResult: null,
        signReviewRemark: null,
        signReviewPerson: null,
        signReviewTime: null,
        returnDocumentStatus: null,
        returnDocumentRemark: null,
        returnDocumentPerson: null,
        returnDocumentTime: null,
        cashRefuel: null,
        designateRefuel: null,
        tollFeeCash: null,
        tollFeeEtc: null,
        forfeit: null,
        informationFee: null,
        minorInformationFee: null,
        repairTruckFee: null,
        serviceStationRepair: null,
        tireFee: null,
        otherFee: null,
        insurancePremium: null,
        vehicleVesselTax: null,
        greatDipperFee: null,
        gasCylinderFee: null,
        expenseTotal: null,
        profit: null,
        pendAccountStatus: null,
        pendAccountPerson: null,
        pendAccountTime: null,
        pendAccountAuditStatus: null,
        pendAccountAuditPerson: null,
        pendAccountAuditTime: null,
        freightBillStatus: null,
        freightBillNumber: null,
        settlementBillStatus: null,
        settlementBillNumber: null,
        profitBillNumber: null,
        invoiceStatus: null,
        invoiceNumber: null,
        invoiceExpressNumber: null,
        returnWayBillMark: null,
        upwardWayBillNumber: null,
        downwardWayBillNumber: null,
        wayBillMark: null,
        transportPlanNumber: null,
        dataRealm: null,
        parkCode: null,
        delFlag: null,
        createBy: null,
        createTime: null,
        updateBy: null,
        updateTime: null
      };
      this.resetForm("form");
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.exitWarehouseIds.length > 1) {
            addWaybillByExitIds(this.exitWarehouseIds, this.form).then(response => {
              this.$modal.msgSuccess("推送运单成功");
              this.open = false;
            });
          } else {
            addWaybill(this.form).then(response => {
              this.$modal.msgSuccess("推送运单成功");
              this.open = false;
            });
          }
        }
      });
    },
    /** 始发流向选择 **/
    handleChangeBeginFlow(value) {
      for(var i = 0; i < this.beginFlowOptions.length; i++){
        if( this.beginFlowOptions[i].flowDirectionName == value){
          let data = {
            flowDirectionId: this.beginFlowOptions[i].flowDirectionId,
            beginFlowClickNumber: this.beginFlowOptions[i].beginFlowClickNumber + 1
          };
          updateFlow(data).then(response => {
//            console.log('this.beginFlowClickNumber +1 success');
          });
          return;
        }
      } 
    },
    /** 目的流向选择 **/
    handleChangeEndFlow(value) {
      for(var i = 0; i < this.endFlowOptions.length; i++){
        if( this.endFlowOptions[i].flowDirectionName == value){
          let data = {
            flowDirectionId: this.endFlowOptions[i].flowDirectionId,
            endFlowClickNumber: this.endFlowOptions[i].endFlowClickNumber + 1
          };
          updateFlow(data).then(response => {
//            console.log('this.endFlowClickNumber +1 success');
          });
          return;
        }
      } 
    },
    /* 发货电话带出信息 */
    handleSendGoodsMobile(mobile) {
      if(mobile) {
        getPersonAddress(mobile).then(response => {
          if(response.data) {
            this.form.sendGoodsPerson = response.data.person;
            this.form.sendGoodsAddress = response.data.address;
            this.form.beginFlowDirection = response.data.direction;
            this.form.sendGoodsCustomer = response.data.customer;
          } else {
            this.form.sendGoodsPerson = '';
            this.form.sendGoodsAddress = '';
            this.form.beginFlowDirection = '';
            this.form.sendGoodsCustomer = '';
          }
        });
      }
    },
    /* 收货电话带出信息 */
    handleReceGoodsMobile(mobile) {
      if(mobile) {
        getPersonAddress(mobile).then(response => {
          if(response.data) {
            this.form.receiveGoodsPerson = response.data.person;
            this.form.receiveGoodsAddress = response.data.address;
            this.form.endFlowDirection = response.data.direction;
            this.form.receiveGoodsCustomer = response.data.customer;
            this.form.receiveGoodsRemark = response.data.remark;
          } else {
            this.form.receiveGoodsPerson = '';
            this.form.receiveGoodsAddress = '';
            this.form.endFlowDirection = '';
            this.form.receiveGoodsCustomer = '';
            this.form.receiveGoodsRemark = '';
          }
        });
      }
    },
    handleChangeToUpperCase(value) {
      this.form.vehicleLicenseNumber = value.toUpperCase();
    },
    /* 车牌号带出信息 */
    handleVehicleLicenseNumber(value) {
//      console.log(value);
      if(value) {
        getDriverMobile(value).then(response => {
          if(response.data) {
            this.form.driverName = response.data.driverName;
            this.form.contactMobile = response.data.contactMobile;
          } else {
            this.form.driverName = '';
            this.form.contactMobile = '';
          }
        });
      }
    },
    getOption() {
      /** 字典项客户*/
      listCustomerOption().then(response => {
        this.customerOptions = response.data;
//        console.log('this.customerOptions',this.customerOptions);
      });
    },
    // 关联计划，相关数据项，收/发货字段
    handleRelatePlan(value) {
      console.log('handleRelatePlan', value);
      if(value) {
        getPlanExt(value).then(response => {
          if(isNotNull(response.data)) {
            // 关联计划，相关数据项，收/发货字段
            this.$set(this.form, 'sendGoodsMobile', response.data.sendGoodsMobile);
            this.$set(this.form, 'sendGoodsPerson', response.data.sendGoodsPerson);
            this.$set(this.form, 'sendGoodsAddress', response.data.sendGoodsAddress);
            this.$set(this.form, 'beginFlowDirection', response.data.beginFlowDirection);
            this.$set(this.form, 'sendGoodsCustomer', response.data.sendGoodsCustomer);
            this.$set(this.form, 'receiveGoodsMobile', response.data.receiveGoodsMobile);
            this.$set(this.form, 'receiveGoodsPerson', response.data.receiveGoodsPerson);
            this.$set(this.form, 'receiveGoodsAddress', response.data.receiveGoodsAddress);
            this.$set(this.form, 'endFlowDirection', response.data.endFlowDirection);
            this.$set(this.form, 'receiveGoodsCustomer', response.data.receiveGoodsCustomer);
            this.$set(this.form, 'receiveGoodsRemark', response.data.receiveGoodsRemark);
            // 填写完整汽运计划编号
            this.$set(this.form, 'transportPlanNumber', response.data.transportPlanNumber);

            this.$message.success('查询到计划信息,' + response.data.transportPlanNumber);
          } else {
            this.$message.error('未查询到计划信息');
          }
        });

      } else {
        this.$message.error('计划编号不能为空');
      }
    },
    /* 变化重计 */
    handleChangeRecompute(value) {
      // 运费相关
      if(this.form.vehicleMark == '外协车辆') {
        if(this.form.freightPriceMode == '按吨') { //按吨
          this.form.freightAmount = (Number(this.form.freightPrice) * Number(this.form.freightWeight)).toFixed(2);
        } else if(this.form.freightPriceMode == '包车') { //包车
          this.form.freightAmount = Number(this.form.freightPrice).toFixed(2);
        } else {
          this.form.freightAmount = 0;
        }
        this.form.freightTotalAmount = (Number(this.form.freightAmount) + Number(this.form.primage) + Number(this.form.minorFreightAmount) 
          - Number(this.form.informationFee) - Number(this.form.minorInformationFee) - Number(this.form.handleCost)).toFixed(2);
        this.form.expenseTotal = this.form.freightTotalAmount;
      } else {
        this.form.expenseTotal = (Number(this.form.freightTotalAmount) + Number(this.form.cashRefuel) 
          + Number(this.form.designateRefuel) + Number(this.form.tollFeeCash) + Number(this.form.tollFeeEtc)
          + Number(this.form.forfeit) + Number(this.form.informationFee) + Number(this.form.minorInformationFee) + Number(this.form.repairTruckFee)
          + Number(this.form.serviceStationRepair) + Number(this.form.tireFee) + Number(this.form.otherFee)
          + Number(this.form.insurancePremium) + Number(this.form.vehicleVesselTax) + Number(this.form.greatDipperFee)
          + Number(this.form.gasCylinderFee)).toFixed(2);
      }
      // 结算费用，主货
      //if(this.form.settlementPrice && this.form.freightWeight) {
        if(this.form.settlementPriceMode == '按吨') { //按吨
          this.form.settlementAmount = (Number(this.form.settlementPrice) * Number(this.form.freightWeight)).toFixed(2);
        } else if(this.form.settlementPriceMode == '包车') { //包车
          this.form.settlementAmount = Number(this.form.settlementPrice).toFixed(2);
        } else {
          this.form.settlementAmount = 0;
        }
      //}
      // 结算费用，配货
      //if((this.form.minorSettlementPrice && this.form.minorFreightWeight) || (this.form.minorSettlementPriceMode == '包车')) {
        if(this.form.minorSettlementPriceMode == '按吨') { //按吨
          this.form.minorSettlementAmount = (Number(this.form.minorSettlementPrice) * Number(this.form.minorFreightWeight)).toFixed(2);
        } else if(this.form.minorSettlementPriceMode == '包车') { //包车
          this.form.minorSettlementAmount = Number(this.form.minorSettlementPrice).toFixed(2);
        } else {
          this.form.minorSettlementAmount = 0;
        }
      //}
      this.form.settlementTotalAmount = (Number(this.form.settlementAmount) + Number(this.form.premium) + Number(this.form.minorSettlementAmount)).toFixed(2);
      this.form.profit = (Number(this.form.settlementTotalAmount) - Number(this.form.expenseTotal)).toFixed(2);
    },
    handleSettlementTotalAmount(value) {
      this.form.settlementTotalAmount = (Number(this.form.settlementAmount) + Number(this.form.premium) + Number(this.form.minorSettlementAmount)).toFixed(2);
      this.form.profit = (Number(this.form.settlementTotalAmount) - Number(this.form.expenseTotal)).toFixed(2);
    },
    handleFreightTotalAmount(value) {
      this.form.freightTotalAmount = (Number(this.form.freightAmount) + Number(this.form.primage) + Number(this.form.minorFreightAmount)).toFixed(2);
      this.form.expenseTotal = (Number(this.form.freightTotalAmount) + Number(this.form.cashRefuel) 
          + Number(this.form.designateRefuel) + Number(this.form.tollFeeCash) + Number(this.form.tollFeeEtc)
          + Number(this.form.forfeit) + Number(this.form.informationFee) + Number(this.form.repairTruckFee)
          + Number(this.form.serviceStationRepair) + Number(this.form.tireFee) + Number(this.form.otherFee)
          + Number(this.form.insurancePremium) + Number(this.form.vehicleVesselTax) + Number(this.form.greatDipperFee)
          + Number(this.form.gasCylinderFee)).toFixed(2);
      this.form.profit = (Number(this.form.settlementTotalAmount) - Number(this.form.expenseTotal)).toFixed(2);
    },
    handleChangeVehicleMark(value) {
      //console.log(value);
      if(value == '自有车辆') {
        this.form.freightPriceMode = '';
      } else {
        this.form.freightPriceMode = '按吨';
      }
      this.form.freightPrice = 0;
      this.form.freightAmount = 0;
      this.form.primage = 0;
      this.form.informationFee = 0;
      this.form.minorInformationFee = 0;
      this.form.handleCost = 0;
      this.form.freightTotalAmount = 0;
      this.form.minorFreightAmount = 0;
      this.form.cashRefuel = this.form.designateRefuel = this.form.tollFeeCash = this.form.tollFeeEtc = this.form.forfeit = this.form.repairTruckFee = this.form.serviceStationRepair = this.form.tireFee = this.form.otherFee = this.form.insurancePremium = this.form.vehicleVesselTax = this.form.greatDipperFee = this.form.gasCylinderFee = 0;
      this.form.expenseTotal = 0;
      this.form.profit = (Number(this.form.settlementTotalAmount) - Number(this.form.expenseTotal)).toFixed(2);
    },
  }
};
</script>

<style scoped lang='less'>
/* 横线 */
.dashed-line{
  border-top: 2px dashed #cac7c7; /* 虚线的宽度、样式和颜色 */
  width: 90%;
  height: 1px;
  margin-left: 40px;
  margin-top: -0.50em;
  margin-bottom: 0.75em;
//  margin:0 auto;
  position: relative;
  text-align: center;
}

//.dashed-line {
//  border-top: 2px dashed #000; /* 虚线的宽度、样式和颜色 */
//  width: 100%; /* 虚线的长度 */
//  margin: 10px 0; /* 虚线的上下间距 */
//}

.el-picker {
  width: 200px !important;
}
.el-select{
  width: 200px;
}
.el-input{
  width: 200px;
}
.address{
  width: 510px;
}

.remark{
  width: 510px;
}

.placeholder {
  flex: 0 0 20%; /* 占位列的宽度 */
}
.spacer {
  flex: 1; /* 占位 */
}
/*/deep/的意思大概为深入的，深远的。Scoped CSS规范是Web组件产生不污染其他组件，也不被其他组件污染的CSS规范。*/
/*在打包的时候会生成一个独一无二hash值，这样父组件的样式就不会影响到子组件了，要想修改子组件的样式，*/
/*一般是提取一个公共文件，在公共文件里面修改样式.提取公共文件的方式来修改，以达到自己想要的，但是同时其他地方也会受到影响*/
/*需要有一个方法或者方式，既不影响到别的地方，又能修改子组件在当前的样式。*/
/deep/.color-date-danger{
  background: red;
}
/deep/.color-date-warning{
  background: rgb(255, 255, 0);
}

</style>